<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Right</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/resources/favicon.ico">
    <link rel="stylesheet" href="resources/layui/css/layui.css" th:href="@{/resources/layui/css/layui.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/resources/css/public.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/resources/layui_ext/dtree/dtree.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/resources/layui_ext/dtree/font/dtreefont.css}" media="all"/>
    <style>
        input#search_provideridTree_select_input_id {
            border-radius: 10px;
            height: 30px;
            margin-top: 4px;
        }
        input#provideridTree_select_input_id {
            border-radius: 10px;
            height: 30px;
            margin-top: 4px;
        }
        input#leaderprovideridTree_select_input_id {
            border-radius: 10px;
            height: 30px;
            margin-top: 4px;
        }
        input.layui-input.layui-unselect {
            border-radius: 10px;
            height: 30px;
            margin-top: 4px;
        }
    </style>
</head>
<body>
<!--查询条件-->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
    <legend>搜索条件</legend>
</fieldset>
<form action="" method="post" id="searchFrm" lay-filter="searchFrm" class="layui-form">
    <div class="layui-form-item">
<!--        <div class="layui-inline">-->
<!--            <label class="layui-form-label">烧伤深度 </label>-->
<!--            <div class="layui-input-inline">-->
<!--                <select name="depth" id="depth">-->
<!--                    <option value="-1">全部</option>-->
<!--                    <option value="0">一度</option>-->
<!--                    <option value="1">浅二度</option>-->
<!--                    <option value="2">深二度</option>-->
<!--                    <option value="3">三度</option>-->
<!--                    <option value="4">数据未录入</option>-->
<!--                </select>-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-inline">
            <label class="layui-form-label">患者编号</label>
            <div class="layui-input-inline">
                <input type="text" name="patientId" id="patientId" class="layui-input input-radius"
                       placeholder="请输入患者编号">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">致伤原因</label>
            <div class="layui-input-inline">
                <input type="text" name="reason" id="reason" class="layui-input input-radius"
                       placeholder="请输入致伤原因">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">烧伤面积</label>
            <div class="layui-input-inline">
                <input type="text" name="area" id="area" class="layui-input input-radius" placeholder="烧伤总面积（平方厘米">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">烧伤部位</label>
            <div class="layui-input-inline">
                <input type="text" name="position" id="position" class="layui-input input-radius"
                       placeholder="请输入烧伤部位">
            </div>
        </div>
        <div class="layui-inline" style="padding-left: 3%">
            <button type="button" class="layui-btn layui-btn-sm layui-btn-radius" lay-submit="" lay-filter="doSearch"><i
                    class="layui-icon layui-icon-search layui-icon-normal"></i>查询
            </button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-warm"><i
                    class="layui-icon layui-icon-refresh"></i><span>重置</span>
            </button>
        </div>
    </div>
</form>

<!--数据表格-->
<div>

    <table class="layui-hide" id="woundTable" lay-filter="woundTable"></table>

    <div id="woundToolBar" style="display: none">
        <button type="button" lay-event="add" class="layui-btn layui-btn-sm layui-btn-normal layui-btn-radius" >
            <i class="layui-icon layui-icon-add-1"></i>添加创面信息
        </button>
        <button type="button" class="layui-btn layui-btn-sm layui-btn-normal layui-btn-radius zipUpLoadBtn" style="margin-left: 0px">
            <i class="layui-icon layui-icon-add-1"></i>批量添加创面信息
        </button>

        <button type="button" lay-submit="" class="layui-btn layui-btn-sm layui-btn-normal layui-btn-radius" lay-filter="explodeData">
            <i class="layui-icon layui-icon-export"></i>数据导出
        </button>

        <button type="button" lay-event="chart" class="layui-btn layui-btn-sm layui-btn-danger layui-btn-radius" lay-filter="explodeData">
            <i class="layui-icon layui-icon-chart"></i>患者烧伤图趋势
        </button>

        <a id="downloadFile" style="display: none"></a>

    </div>
    <div id="woundRowBar" style="display: none;">
        <button type="button" lay-event="update" class="layui-btn layui-btn-sm layui-btn-radius"><i
                class="layui-icon layui-icon-edit"></i>编辑
        </button>

        <button id="showOrNot" type="button" lay-event="delete" class="layui-btn layui-btn-sm layui-btn-danger layui-btn-radius"><i
                class="layui-icon layui-icon-delete"></i>删除
        </button>
    </div>
</div>

<!--添加和修改的弹出层-->
<div id="addOrUpdateDiv" style="display: none;padding: 10px;padding-right: 5%">
    <form action="" method="post" class="layui-form" id="dataFrm" lay-filter="dataFrm">
        <div class="layui-col-md12 layui-col-xs12">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md9 layui-col-xs7">
<!--                    <div class="layui-form-item magt3">-->
<!--                        &lt;!&ndash;隐藏的id&ndash;&gt;-->
<!--                        <input type="hidden" class="layui-input input-radius" name="id">-->
<!--                        <label class="layui-form-labFel">烧伤深度</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <select name="depth">-->
<!--                                <option value="0">一度</option>-->
<!--                                <option value="1">浅二度</option>-->
<!--                                <option value="2">深二度</option>-->
<!--                                <option value="3">三度</option>-->
<!--                                <option value="4">数据未录入</option>-->
<!--                            </select>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="layui-form-item">-->
<!--                        <label class="layui-form-label">照片编号</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <input type="hidden" name="id">-->
<!--                            <input type="text" class="layui-input input-radius layui-disabled" name="pictureId" lay-verify="required" placeholder="照片编号自动生成">-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">患者编号</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input input-radius" name="patientId" lay-verify="required" placeholder="请输入患者编号">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">患者姓名</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input input-radius" name="name" lay-verify="required" placeholder="请输入患者姓名">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md3 layui-col-xs5">
                    <div class="layui-upload-list thumbBox mag0 magt3">
                        <input type="hidden" name="picturePath" id="picturePath" value="/defaultImage.jpg">
                        <img class="layui-upload-img thumbImg" src="/file/loadCMImg?path=/defaultImage.jpg">
                    </div>
                </div>
            </div>
            <div class="layui-form-item magb0">
                <div class="layui-inline">
                    <label class="layui-form-label">患者年龄</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="age" lay-verify="required" placeholder="年龄（岁，未录入请填-1）">
                    </div>
                    <label class="layui-form-label">患者性别</label>
                    <div class="layui-input-inline">
                        <select name="sex">
                            <option value="0">女</option>
                            <option value="1">男</option>
                            <option value="2">数据未录入</option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">患者身高</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="height" lay-verify="required" placeholder="身高（厘米，未录入请填-1）">
                    </div>
                    <label class="layui-form-label">患者体重</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="weight" lay-verify="required" placeholder="体重（千克，未录入请填-1）">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">烧伤总面积</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="area" lay-verify="required" placeholder="烧伤总面积（平方厘米，未录入请填-1）">
                    </div>

                    <label class="layui-form-label">致伤原因</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="reason" lay-verify="required" placeholder="请输入致伤原因">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">伤后几天</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="afterHurtDay" lay-verify="required" placeholder="（天，未录入请填-1）">
                    </div>

                    <label class="layui-form-label">治愈时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="cureDay" lay-verify="required" placeholder="（天，未录入请填-1）">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">烧伤部位</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="position" lay-verify="required" placeholder="请输入烧伤部位">
                    </div>
                    <label class="layui-form-label">创面感染</label>
                    <div class="layui-input-inline">
                        <select name="hasInfected">
                            <option value="0">是</option>
                            <option value="1">否</option>
                            <option value="2">数据未录入</option>
                        </select>
                    </div>
                </div>

<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">合并并发症</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" class="layui-input input-radius" name="complications" lay-verify="required" placeholder="请输入合并并发症">-->
<!--                    </div>-->
<!--                    <label class="layui-form-label">愈合情况</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" class="layui-input input-radius" name="healing" lay-verify="required" placeholder="请输入愈合情况">-->
<!--                    </div>-->
<!--                </div>-->


<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">是否冷疗</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <select name="hasLenLiao">-->
<!--                            <option value="0">是</option>-->
<!--                            <option value="1">否</option>-->
<!--                            <option value="2">数据未录入</option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                    <label class="layui-form-label">胶原酶使用</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <select name="hasJiaoYuanMei">-->
<!--                            <option value="0">是</option>-->
<!--                            <option value="1">否</option>-->
<!--                            <option value="2">数据未录入</option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                </div>-->

<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">敷料类型</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <select name="fuLiaoType">-->
<!--                            <option value="0">生物敷料</option>-->
<!--                            <option value="1">合成敷料</option>-->
<!--                            <option value="2">传统纱布</option>-->
<!--                            <option value="3">数据未录入</option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                    <label class="layui-form-label">敷料明细</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" class="layui-input input-radius" name="fuLiaoDetail" lay-verify="required" placeholder="请输入具体敷料明细">-->
<!--                    </div>-->
<!--                </div>-->

<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">是否清创</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <select name="hasQingChuang">-->
<!--                            <option value="0">是</option>-->
<!--                            <option value="1">否</option>-->
<!--                            <option value="2">数据未录入</option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                    <label class="layui-form-label">清创手术</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="tel" name="qingChuangTime" id="qingChuangTime" readonly="readonly" placeholder="yyyy-MM-dd" class="layui-input">-->
<!--                    </div>-->
<!--                </div>-->

<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">是否植皮</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <select name="hasZhiPi">-->
<!--                            <option value="0">是</option>-->
<!--                            <option value="1">否</option>-->
<!--                            <option value="2">否</option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                    <label class="layui-form-label">植皮时间</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="tel" name="zhiPiTime" id="zhiPiTime" readonly="readonly" placeholder="yyyy-MM-dd" class="layui-input">-->
<!--                    </div>-->
<!--                </div>-->

<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">植皮厚度</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <select name="zhiPiDepth">-->
<!--                            <option value="0">未植皮</option>-->
<!--                            <option value="1">刃厚</option>-->
<!--                            <option value="2">中厚</option>-->
<!--                            <option value="3">全厚</option>-->
<!--                            <option value="4">数据未录入</option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                    <label class="layui-form-label">植皮类型</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" class="layui-input input-radius" name="zhiPiType" lay-verify="required" placeholder="请输入植皮具体类型">-->
<!--                    </div>-->
<!--                </div>-->

<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">换药疼痛评分</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" class="layui-input input-radius" name="painScore" lay-verify="required" placeholder="请输入换药疼痛评分">-->
<!--                    </div>-->
<!--                    <label class="layui-form-label">创面炎症评分</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" class="layui-input input-radius" name="yanzhengScore" lay-verify="required" placeholder="请输入创面炎症评分">-->
<!--                    </div>-->
<!--                </div>-->

            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block" style="text-align: center;padding-right: 7%">
                <button type="button" class="layui-btn layui-btn-radius" lay-submit="" lay-filter="doSubmit" id="doSubmit"><i
                        class="layui-icon layui-icon-search layui-icon-normal"></i>提交
                </button>
                <button type="reset" class="layui-btn layui-btn-radius layui-btn-warm"><i
                        class="layui-icon layui-icon-refresh"></i><span>重置</span>
                </button>
            </div>
        </div>
    </form>
</div>

<!--Author:qtck-->
<!--绘制图表-->
<div id="chartContainer" style="width: 100%; height: 500px;"></div>

</div>


<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>


<!--判断用户名，如果是admin，才显示删除按钮，如果不是，就不显示。AUTHOR：qtck-->
<script>
    loginName = window.localStorage.getItem("loginName");
    console.log(loginName);
    if(loginName !== "admin")
        document.getElementById("showOrNot").style.display = "none";
</script>

<script type="text/javascript">
<!--    声明禁用域对应的索引，AUTHOR：qtck-->
    var fields = [
        { name: 'age', index: 0 },
        { name: 'sex', index: 0 },
        { name: 'patientId', index: 1 },
        { name: 'name', index: 0 },
        { name: 'height', index: 0 },
        { name: 'weight', index: 0 },
        { name: 'reason', index: 1 },
        { name: 'cureDay', index: 0 },
        { name: 'position', index: 1 },
        { name: 'hasInfected', index: 0 }
    ];

    layui.config({
        base: '/resources/layui_ext/',//静态资源所在路径
    }).extend({
        excel: 'excel',
    });


    //提升数据表格的作用域，因为底下还有一个reloadTable方法
    var tableIns;

    var queryData={'depth':'-1','patientId':'','reason':'','area':'','position':''};

    layui.use(['jquery', 'form', 'layer', 'table','upload','excel','laydate'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var layer = layui.layer;
        var table = layui.table;
        var upload = layui.upload;
        // var depth_dic = {0:"一度", 1:"浅二度", 2:"深二度", 3:"三度",4:"数据未录入"};
        // var fu_liao_type_dic = {0:"生物敷料", 1:"合成敷料", 2:"传统纱布",3:"数据未录入"};
        // var zhi_pi_depth_dic = {0:'未植皮',1:"刃厚", 2:"中厚", 3:"全厚",4:"数据未录入"};
        var sex_dic = {0:"女", 1:"男",2:"数据未录入",3:"数据未录入"};
        var true_false_dic = {0:"是", 1:"否",2:"数据未录入"};
        var excel=layui.excel;
        var laydate=layui.laydate;
        var area = [];   //表格加载完成后，伤口面积数据将存入内部
        var afterHurtDay = [];   //表格加载完成后，受伤天数数据将存入内部

        //初始化时间选择器
        laydate.render({
            elem:'#qingChuangTime',
            type:'date'
        });
        laydate.render({
            elem:'#zhiPiTime',
            type:'date'
        });

        //初始化表格 加载数据
        tableIns = table.render({
            elem: "#woundTable",
            title: "创面信息表格",
            url: "/wound/loadAllWound",
            toolbar: "#woundToolBar",
            page: true,
            height: "full-180",
            cols: [ [
                //{field: 'id', title: 'ID', align: 'center',width:'50'},
                {field: 'pictureId', title: '照片编号', align: 'center',width:'100'},
                {field: 'picturePath', title: '照片', align: 'center',width:'150',
                    templet:function (d) {
                        return '<div id="clickBigger" style="cursor: pointer"><img width=40 height=40 src=/file/loadCMImg?path='+d.picturePath+ ' /></div>';
                    }},
                {field: 'patientId', title: '患者编号', align: 'center',width:'90'},
                {field: 'name', title: '姓名', align: 'center',width:'90'},
                {field: 'age', title: '年龄（岁）', align: 'center',width:'90'},
                {field: 'sex', title: '性别', align: 'center',width:'90',
                    templet:function (d) {
                        return sex_dic[d.sex]
                    }},
                {field: 'height', title: '身高（厘米）', align: 'center',width:'90',
                    templet:function (d) {
                        if (d.height==-1) return "数据未录入"
                        return d.height
                    }},
                {field: 'weight', title: '体重（千克）', align: 'center',width:'90',
                    templet:function (d) {
                        if (d.weight==-1) return "数据未录入"
                        return d.weight
                    }},
                {field: 'afterHurtDay', title: '伤后第几天（天）', align: 'center',width:'90'},
                {field: 'cureDay', title: '治愈时间（天）', align: 'center',width:'90'},
                {field: 'reason', title: '致伤原因', align: 'center',width:'120'},
                {field: 'area', title: '烧伤总面积（平方厘米）', align: 'center',width:'90',
                    templet:function (d) {
                        if (d.area==-1) return "数据未录入"
                        return d.area
                    }},
                // {field: 'depth', title: '烧伤深度', align: 'center',width:'100',
                //     templet:function (d) {
                //         return depth_dic[d.depth]
                //     }},
                {field: 'position', title: '烧伤部位', align: 'center',width:'90'},
                {field: 'hasInfected', title: '是否创面感染', align: 'center',width:'90',
                    templet:function (d) {
                        return true_false_dic[d.hasInfected]
                    }},
                // {field: 'complications', title: '合并并发症', align: 'center',width:'150'},
                // {field: 'healing', title: '愈合情况', align: 'center',width:'150'},
                // {field: 'hasLenLiao', title: '是否冷疗', align: 'center',width:'90',
                //     templet:function (d) {
                //         return true_false_dic[d.hasLenLiao]
                //     }},
                // {field: 'hasJiaoYuanMei', title: '是否使用胶原酶', align: 'center',width:'90',
                //     templet:function (d) {
                //         return true_false_dic[d.hasJiaoYuanMei]
                //     }},
                // {field: 'fuLiaoType', title: '敷料类型', align: 'center',width:'100',
                //     templet:function (d) {
                //         return fu_liao_type_dic[d.fuLiaoType]
                //     }},
                // {field: 'fuLiaoDetail', title: '具体敷料明细', align: 'center',width:'150'},
                // {field: 'hasQingChuang', title: '是否清创', align: 'center',width:'90',
                //     templet:function (d) {
                //         return true_false_dic[d.hasQingChuang]
                //     }},
                // {field: 'qingChuangTime', title: '清创手术时间', align: 'center',width:'150'},
                // {field: 'hasZhiPi', title: '是否植皮', align: 'center',width:'90',
                //     templet:function (d) {
                //         return true_false_dic[d.hasZhiPi]
                //     }},
                // {field: 'zhiPiTime', title: '植皮时间', align: 'center',width:'150'},
                // {field: 'zhiPiDepth', title: '植皮厚度', align: 'center',width:'100',
                //     templet:function (d) {
                //         return zhi_pi_depth_dic[d.zhiPiDepth]
                //     }},
                // {field: 'zhiPiType', title: '植皮具体类型', align: 'center',width:'150'},
                // {field: 'painScore', title: '换药疼痛评分', align: 'center',width:'150'},
                // {field: 'yanzhengScore', title: '创面炎症评分', align: 'center',width:'150'},
                {field: 'changeTime', title: '图片上传时间', align: 'center',width:'150'},
                {fixed: 'right', title: '操作', toolbar: '#woundRowBar', align: 'center',width:'180'}
            ] ],
            /**
             * 作用：获得回调的数据，将其存储在数组中，并且最后展示在echarts内
             * @author qtck
             * @param data
             * @param curr
             * @param count
             */
            done: function (data, curr, count) {
                //将数据传入定义的area和afterHurtDay全局数组内
                //1.获取当前表格中的所有数据
                let tableData = data.data;
                //直接对对象数组进行排序，按照其中的afterHurtDay的大小
                tableData.sort(function (a,b){
                    let d1 = a.afterHurtDay;
                    let d2 = b.afterHurtDay;
                    return d1 - d2;
                })

                //2.遍历表格数据，将烧伤总面积数据放入数组中
                tableData.forEach(function (item){
                   area.push(item.area);
                   afterHurtDay.push(item.afterHurtDay);
                });
                // console.log(afterHurtDay);
                // console.log(area);

                //不是第一页时，如果当前返回的数据为0那么就返回上一页
                if (data.data.length == 0 && curr != 1) {
                    tableIns.reload({
                        page: {
                            curr: curr - 1
                        }
                    })
                }
            }
        });

        /**
         * 点击图片，在弹出层展示
         * @Author: qtck
         */
        $(document).on('click', '#clickBigger img', function () {
            var src = $(this).attr('src');
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                area: ['600px', '600px'],
                skin: 'layui-layer-nobg', //没有背景色
                shadeClose: true,
                content: '<img src="' + src + '" style="width:600px;height:600px;"/>'
            });
        });

        // $(document).on('click', '#clickBigger img', function () {
        //     var src = $(this).attr('src');
        //     var img = new Image();
        //     img.onload = function() {
        //         var width = this.width;
        //         var height = this.height;
        //         layer.open({
        //             type: 1,
        //             title: false,
        //             closeBtn: 0,
        //             area: [width + 'px', height + 'px'], // 根据图片宽高设置layer宽高
        //             skin: 'layui-layer-nobg', //没有背景色
        //             shadeClose: true,
        //             content: '<img src="' + src + '" style="width:' + width + 'px;height:' + height + 'px;"/>'
        //         });
        //     };
        //     img.src = src;
        // });



        //数据导出
        form.on('submit(explodeData)', function (data) {
            layer.load();
            $.post("/wound/loadWoundZip",queryData,function (res) {
                if (res.data.path){
                    downloadFile("/file/loadCMZip?path="+res.data.path,"result.zip")
                    $.post("/wound/deleteWoundZip",{"path":res.data.path},function (res) {
                        layer.closeAll('loading');
                        layer.msg("数据导出成功");
                    });
                }
            });
        });
        function downloadFile(filePath,name) {
            const link = document.getElementById('downloadFile')
            link.href = filePath
            link.setAttribute(
                'download',
                name
            )
            link.click()
        }







        /**
         * 监控模糊查询按钮事件
         * 并在监听到数据查询变动的时候，会改变这两个数组中的内容
         * @author qtck
         */
        form.on("submit(doSearch)", function (data) {
            queryData=data.field
            //先清空数组
            area = [];
            afterHurtDay = [];
            tableIns.reload({
                where: data.field,
                page: {
                    curr: 1
                },
                //又是一个回调函数
                done:function (data,curr,count){
                    //1.获取当前表格中的所有数据
                    let tableData = data.data;
                    //直接对对象数组进行排序，按照其中的afterHurtDay的大小
                    tableData.sort(function (a,b){
                        let d1 = a.afterHurtDay;
                        let d2 = b.afterHurtDay;
                        return d1 - d2;
                    })
                    //2.遍历表格数据，将烧伤总面积数据放入数组中
                    tableData.forEach(function (item){
                        area.push(item.area);
                        afterHurtDay.push(item.afterHurtDay);
                    });
                }
            });
            return false;
        });

        //监控工具条事件
        table.on("toolbar(woundTable)", function (obj) {
            switch (obj.event) {
                case 'add':
                    openAddLayer();
                    break;
                case 'chart':
                    openChartLayer();
                    break;
            };
        });


        //监控行工具条事件
        table.on("tool(woundTable)", function (obj) {
            //获取当前行数据
            var data = obj.data;
            switch (obj.event) {
                case 'delete':
                    deleteGoods(data);
                    break;
                case 'update':
                    updateGoods(data);
                    break;
            };
        });

        //图片上传
        upload.render({
            elem: '.thumbBox',
            url: '/file/uploadCMImg',
            acceptMime:'image/*',
            field:'mf',
            data: {
                oldPicturePath: function(){
                    return $("#picturePath").val();
                }
            },
            method : "post",
            done: function(res, index, upload){
                if(res.data.path)
                {
                    var path=res.data.path;
                    $('.thumbImg').attr('src','/file/loadCMImg?path='+path);
                    $('.thumbBox').css("background","#fff");
                    //给隐藏域赋值
                    $("#picturePath").val(path);
                }
            }
        });

        //zip上传
        upload.render({
            elem: '.zipUpLoadBtn',
            url: '/wound/addWoundZip',
            exts: 'zip',
            field:'mf',
            method : "post",
            before: function(obj){
                layer.load();
            },
            done: function(res){
                layer.closeAll('loading');
                if(res.code==200)
                {
                    layer.msg("批量添加成功");
                    tableIns.reload();
                }else{
                    layer.msg(res.data);
                }
            }
        });

        var mainIndex;
        var url;

        //打开添加弹出层
        function openAddLayer() {
            mainIndex = layer.open({
                type:1,
                content:$("#addOrUpdateDiv"),
                area:['700px','550px'],
                title:'添加创面信息',
                success:function () {
                    //把修改的权限开出来
                    fields.forEach(function (field) {
                        let element = document.getElementsByName(field.name)[field.index];
                        element.disabled = false;
                    });
                    $("#dataFrm")[0].reset();
                    //设置默认为无图片
                    $(".thumbImg").attr("src","/file/loadCMImg?path=/defaultImage.jpg");
                    $("#picturePath").val('/defaultImage.jpg');
                    url="/wound/addWound";
                }
            });
        }


        /**
         * 打开应该画出的图像
         * @Author qtck
         */
        function openChartLayer() {

            let chart = echarts.init(document.getElementById('chartContainer'));

            // 使用处理后的数据生成图表
            let option = {
                xAxis: {
                    type: 'category',
                    data: afterHurtDay
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: area,
                    type: 'line',
                    smooth: true,
                    label:{
                        show:true,  //是否可见
                        rotate:0   //数字的旋转角度
                    }
                }]
            };

            // 将图表数据设置到echarts实例中
            chart.setOption(option);
            // 使用layui的弹出层打开图表
            layer.open({
                type: 1,
                title: '患者烧伤图趋势',
                content: $('#chartContainer'),
                area: ['100%', '90%'],
                shadeClose: true
            });

        }


        /**
         * 打开修改的弹出层
         * @param data
         * @author qtck
         */
        function updateGoods(data) {
            mainIndex = layer.open({
                type:1,
                content:$("#addOrUpdateDiv"),
                area:['700px','550px'],
                title:'修改创面信息',
                success:function () {
                    //清空原有的数据
                    $("#dataFrm")[0].reset();
                    //装载新的数据
                    form.val("dataFrm",data);
                    //如果当前用户不为admin，直接把这几个按钮禁用掉
                    if(window.localStorage.getItem("loginName")!=="admin"){
                        //遍历上面定义的禁用域数组，禁用表单元素
                        fields.forEach(function (field) {
                            let element = document.getElementsByName(field.name)[field.index];
                            element.disabled = true;
                        });
                    }
                    //图片进行回显
                    $(".thumbImg").attr("src","/file/loadCMImg?path="+data.picturePath);
                    //下拉列表的回显
                    url="/wound/updateWound";
                }
            });
        }





        form.on("submit(doSubmit)",function (data) {
            console.log(data.field)
            $.post(url,data.field,function (res) {
                if (res.code==200){
                    tableIns.reload();
                }
                layer.msg(res.msg);
                layer.close(mainIndex);
            });
            return false;
        });

        //删除
        function deleteGoods(data) {
            layer.confirm('你确定要删除编号为【' + data.pictureId + '】的图片吗？', {icon: 3, title: '提示'}, function (index) {
                $.post("/wound/deleteWound", {id: data.id,picturePath:data.picturePath},function (res) {
                    if(res.code==200){
                        tableIns.reload({
                            where:"",
                        });
                    }
                    layer.msg(res.msg);
                });
                layer.close(index);
            });
        }


    });


</script>

</body>
</html>